package team.star.werespos.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import team.star.werespos.model.entity.Permission;

/**
 * PermissionMapper interface<br/>
 *
 * @author CAI
 * @since 2019/04/09
 */
public interface PermissionMapper extends BaseMapper<Permission> {

    @Select("SELECT u.*, r.*, p.* " +
            "FROM `role` u " +
            "  INNER JOIN `user_role` ur ON ur.uid = u.uid " +
            "  INNER JOIN `role` r ON r.rid = ur.rid " +
            "  INNER JOIN `permission_role` pr ON pr.rid = r.rid " +
            "  INNER JOIN `permission` p ON pr.pid = p.pid " +
            "WHERE u.pname = #{pname} ")
    Permission findByUsername(@Param("pname") String pname);
}



